package com.yunshipei.service;

import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.util.Log;

import com.yunshipei.common.Globals;

import io.rong.imkit.RongContext;
import io.rong.push.notification.PushMessageReceiver;
import io.rong.push.notification.PushNotificationMessage;

/**
 * Created by cike on 16/6/12.
 */
public class EnterplorerNotificationReceiver extends PushMessageReceiver {
    @Override
    public boolean onNotificationMessageArrived(Context context, PushNotificationMessage pushNotificationMessage) {
        Log.e(EnterplorerNotificationReceiver.class.getSimpleName(), "收到融云推送的消息");
//        new EnterplorerNotificationManager.Builder().setContext(context).build().showNotification(pushNotificationMessage);
        return false;
    }

    @Override
    public boolean onNotificationMessageClicked(Context context, PushNotificationMessage pushNotificationMessage) {
        Intent intent = new Intent();
        Uri uri = Uri.parse("rong://" + RongContext.getInstance().getPackageName()).buildUpon().appendPath("conversation")
                .appendPath(pushNotificationMessage.getConversationType().getName())
                .appendQueryParameter("targetId", pushNotificationMessage.getTargetId()).build();
        intent.setData(uri);
        intent.putExtra(Globals.NOTIFICATIONSTATE, true);
        intent.putExtra(Globals.NOTIFICATIONWHERE, false);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        context.startActivity(intent);
        return true;
    }
}
